/*
 * Copyright (c) 2005, 2014 vacoor
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 */
package org.vacoor.nothing.security.service.impl;

import org.springframework.cache.annotation.CachePut;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import org.vacoor.nothing.security.entity.Role;
import org.vacoor.nothing.security.service.RoleService;
import org.vacoor.nothing.web.service.support.CrudServiceImpl;

import java.util.List;
import java.util.Map;

/**
 * @author vacoor
 */
@Service
public class RoleServiceImpl extends CrudServiceImpl<Role, String> implements RoleService {

    @Cacheable("shiro-activeSessionCache")
    @Override
    public Role find(String s) {
        return super.find(s);
    }

    @CachePut("shiro-activeSessionCache")
    @Override
    public List<Role> findMany(Map<String, Object> params) {
        return super.findMany(params);
    }

    @Override
    public List<Role> findRolesByUsername(String username) {
        return findMany("users.username", username);
    }

}
